Read Consistency Strategy: Adds hub region header for LastCommittedSingleWriteRegion strategy.#5815
Conversation
|
Azure Pipelines: Successfully started running 1 pipeline(s). |
|
@sdkReviewAgent-2 |
|
✅ Review complete (55:02) Posted 2 inline comment(s). Steps: ✓ context, correctness, cross-sdk, design, history, past-prs, synthesis, test-coverage |
kushagraThapar
left a comment
There was a problem hiding this comment.
Now that we always route requests to hub region, what happens if customers set this in case of multi-writer account?
FabianMeiswinkel
left a comment
There was a problem hiding this comment.
Hubregion processing should only be triggered by a single ReadConsistencyStartegy enum value - like LastCommittedWriteRegion or similar. Not for all ReadConsistencyStartegies for sure!
…stencyStrategy and only for read operation type
|
Azure Pipelines: Successfully started running 1 pipeline(s). |
|
Azure Pipelines: Successfully started running 1 pipeline(s). |
|
Azure Pipelines: Successfully started running 1 pipeline(s). |
|
Azure Pipelines: Successfully started running 1 pipeline(s). |
b9070dd to
dac78b4
Compare
…r read consistency strategy
7896535 to
9ac50cd
Compare
NaluTripician
left a comment
There was a problem hiding this comment.
A few changes might be needed but other than that LGTM
kushagraThapar
left a comment
There was a problem hiding this comment.
Requesting changelog entry.
69b12ad
updated changelog |
kushagraThapar
left a comment
There was a problem hiding this comment.
LGTM, thanks @aavasthy for adding the changelog entry :)
Adds a new Unreleased Preview section (per the pattern established in PR #5815) with a Fixed entry for PR #5844. Customer-facing description focuses on the symptom (premature OperationCanceledException preempting cross-region failover during metadata-cache reads) rather than the implementation detail (the new MetadataDetachedExecutor). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Pull Request Template
Description
Direct package update to 4.43.1:
Merged PRs:
Update logic for ReadConsistencyStrategy header parsing and fallback improvements
https://msdata.visualstudio.com/CosmosDB/_git/CosmosDB/pullrequest/2075563
Add LastCommittedSingleWriteRegion Read Consistency Strategy
https://msdata.visualstudio.com/CosmosDB/_git/CosmosDB/pullrequest/2089383
DTC Status Codes and SubStatus Codes Generation
https://msdata.visualstudio.com/CosmosDB/_git/CosmosDB/pullrequest/2030762?
This PR introduces a new LastCommittedWriteRegion value to the ReadConsistencyStrategy enum, enabling reads to be routed to the hub (write) region so they always reflect the most recent writes regardless of which region the client is connected to. When this strategy is set either at the client or request level and the operation is a read (point read, query, change feed, or ReadMany), the SDK additionally sets the ShouldProcessOnlyInHubRegion header so the backend routes the request to the write region. The header is only applied for read operations and is not set for writes.
Hedging request with hub region header:
When CrossRegionHedgingAvailabilityStrategy is active, the primary request may discover the hub region mid-flight
(after 2× 404/1002 triggers addHubRegionProcessingOnlyHeader = true in ClientRetryPolicy). Hedged requests are
clones of the original and run with their own ClientRetryPolicy instance, so they would normally repeat the entire
hub discovery cycle independently. To avoid this redundant retry overhead, we introduce a
CrossRegionAvailabilityContext — a lightweight shared object with a volatile bool
ShouldAddHubRegionProcessingOnlyHeader flag. This context is injected into RequestMessage.Properties before the
clone loop in CrossRegionHedgingAvailabilityStrategy. Since Clone() performs a shallow dictionary copy, all clones
(primary + hedges) share the same CrossRegionAvailabilityContext reference. When the primary's ClientRetryPolicy
sets the hub flag after 2× 404/1002, it also sets the flag on the shared context. Each hedge's
ClientRetryPolicy.OnBeforeSendRequest reads this shared flag on every attempt and attaches the
x-ms-cosmos-hub-region-processing-only header immediately — without needing to go through its own 404/1002
discovery.
Type of change
Please delete options that are not relevant.
Closing issues
To automatically close an issue: closes #IssueNumber